home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / util / archie18.1 < prev    next >
Internet Message Format  |  1989-07-11  |  10KB

  1. Path: xanth!ames!apple!sun-barr!newstop!sun!swap!page
  2. From: page%swap@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i162:  archie - backup utility in rexx v1.8
  5. Message-ID: <114882@sun.Eng.Sun.COM>
  6. Date: 11 Jul 89 23:19:03 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 324
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: cb@frambo.dec.com (Christian Balzer)
  12. Posting-number: Volume 89, Issue 162
  13. Archive-name: util/archie18.1
  14.  
  15. Archie will copy all files that don't have the archive bit set from SOURCE
  16. and it's subdirectories to DESTINATION. If these directories don't exist at
  17. DESTINATION, Archie will try to create them on the fly preserving the
  18. original structure at SOURCE.  After the file has been copied, its archive
  19. bit will be set.
  20.  
  21. # This is a shell archive.
  22. # Remove anything above and including the cut line.
  23. # Then run the rest of the file through 'sh'.
  24. # Unpacked files will be owned by you and have default permissions.
  25. #----cut here-----cut here-----cut here-----cut here----#
  26. #!/bin/sh
  27. # shar: SHell ARchive
  28. # Run the following text through 'sh' to create:
  29. #    archie.rexx
  30. #    equal.rexx
  31. # This is archive 1 of a 1-part kit.
  32. # This archive created: Tue Jul 11 16:14:46 1989
  33. echo "extracting archie.rexx"
  34. sed 's/^X//' << \SHAR_EOF > archie.rexx
  35. X/* Archie.rexx -- a backup utility by <CB> aka Christian Balzer
  36. X   based on du.rexx by Larry Phillips.
  37. X    _  _
  38. X / /  | \ \  <CB> aka Christian Balzer  - The Software Brewery -
  39. X< <   |-<  > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com
  40. X \ \_ |_/ /  CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!)
  41. X------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G.
  42. X
  43. XUsage: [rx] Archie SOURCE DESTINATION [-options]
  44. X
  45. XSOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing
  46. Xslashes '/'.
  47. XValid options are: Currently none...
  48. X
  49. XArchie will copy all files that don't have the archive bit set
  50. Xfrom SOURCE and it's subdirectories to DESTINATION. If these
  51. Xdirectories don't exist at DESTINATION, Archie will try to create
  52. Xthem on the fly and thus preserving the original structure at SOURCE.
  53. XAfter the file has been copied, it's archive bit will be set.
  54. X
  55. XNote: The files will be copied with 'CLONE' flag of the COPY command
  56. Xset. This of course only works with the 1.3 version of COPY.
  57. XIn this version of Archie, filenames or directories containing blanks
  58. X(like "My Dir:My File"), are NOT supported!
  59. XIn version 1.7 the form "a add" for Protect was changed to "add a" to
  60. Xsupport the ARP 1.3 protect command which isn't fully compatible.  */
  61. X
  62. X/* This is Public Domain, read the source and learn */
  63. X
  64. Xsay 'Archie 1.8 (05-May-89) by <CB>'
  65. X
  66. X/* open the Rexx support library */
  67. X
  68. Xif ~show('L',"rexxsupport.library") then do
  69. X   if addlib('rexxsupport.library',0,-30,0) then
  70. X      say 'added rexxsupport.library'
  71. X   else do;
  72. X      say 'support library not available'
  73. X      exit 10
  74. X      end
  75. X   end
  76. X
  77. Xaddress command
  78. Xcall pragma 'priority',-1
  79. X
  80. Xarg rein
  81. X
  82. X/* The parser */
  83. Xcopt = 'clone'
  84. X
  85. Xif words(rein) < 2 then do
  86. X        say 'Come on, gimme a SOURCE *AND* a DESTINATION path'
  87. X        say 'Ya better try again... Bye!'
  88. X        exit 10
  89. Xend
  90. X
  91. X
  92. Xroot = subword(rein,1,1)
  93. Xdest = subword(rein,2,1)
  94. X
  95. Xif ~ exists(root) then do
  96. X        say 'Source not found'
  97. X        say 'Exiting... Check your parameters'
  98. X        exit 10
  99. Xend
  100. X
  101. Xif ~ exists(dest) then do
  102. X        say 'Destination not found'
  103. X        say 'I''ll try to create it for you...'
  104. X        'makedir 'dest
  105. X        if ~ exists(dest) then do
  106. X                say 'Exiting... Check your parameters'
  107. X                exit 15
  108. X        end
  109. X        say 'Created 'dest
  110. Xend
  111. X
  112. Xif right(root,1) ~= ':' then
  113. X  root = root || '/'
  114. Xif root = '/' then root = ''
  115. X
  116. Xif right(dest,1) ~= ':' then
  117. X  dest = dest || '/'
  118. Xif dest = '/' then dest = ''
  119. X
  120. Xrlen = length(root)
  121. X
  122. Xbytes = 0
  123. Xblocks = 0
  124. Xfiles = 0
  125. Xdircount = 1
  126. X
  127. Xsay 'Archie is doing it''s job on 'root
  128. X
  129. Xcall dolist(root)
  130. X
  131. Xsay 'Archived:' bytes 'bytes,' blocks 'blocks, ',
  132. Xfiles 'files in a total 'dircount' directories.'
  133. Xsay
  134. Xexit 0
  135. X .
  136. X
  137. X/* The real thing */
  138. X
  139. Xdolist: procedure expose bytes blocks files dest rlen dircount copt
  140. Xparse arg x
  141. Xcontents = showdir(x);
  142. Xdo i = 1 to words(contents)
  143. X  temp = x || word(contents,i)
  144. X  flen = length(word(contents,i))
  145. X  type = statef(temp)
  146. X  if word(type,1) = 'FILE' then
  147. X    do
  148. X      if substr(word(type,4),4,1) = '-' then
  149. X        do
  150. X                target = dest || right(temp,(length(temp) - rlen))
  151. X                target = left(target,(length(target) - flen))
  152. X                'copy 'temp target copt
  153. X/*              if RC > 0 then
  154. X                  say 'Error archiving 'temp
  155. X                else */
  156. X                do
  157. X                  files = files + 1
  158. X                  bytes = bytes + word(type,2)
  159. X                  blocks = blocks + word(type,3) + 1
  160. X                  'protect 'temp 'add a'
  161. X/*                if RC > 0 then
  162. X                    say 'Error protecting 'temp
  163. X                  else */
  164. X                  say 'Archived: 'temp
  165. X                end
  166. X        end
  167. X    end
  168. X  if word(type,1) ='DIR' then do
  169. X        subdir = dest || right(temp,(length(temp) - rlen))
  170. X        if ~ exists(subdir) then
  171. X          do
  172. X            'makedir' subdir
  173. X            if ~ exists(subdir) then do
  174. X              say 'Sorry... Exiting'
  175. X              exit 20
  176. X            end
  177. X            say ' *** Created directory' subdir
  178. X          end
  179. X        call dolist(temp || '/')
  180. X        dircount = dircount + 1
  181. X  end
  182. Xend
  183. Xreturn
  184. SHAR_EOF
  185. echo "extracting equal.rexx"
  186. sed 's/^X//' << \SHAR_EOF > equal.rexx
  187. X/* equalize.rexx -- a utility for Archie by Christian '<CB>' Balzer
  188. X
  189. X--  _  _
  190. X / /  | \ \  <CB> aka Christian Balzer  - The Software Brewery -
  191. X< <   |-<  > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com
  192. X \ \_ |_/ /  CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!)
  193. X------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G.
  194. X
  195. XUsage: [rx] equalize SOURCE DESTINATION [-options]
  196. X
  197. XSOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing
  198. Xslashes '/'.
  199. XValid options are: -p   This option will only print the differing
  200. X                        filenames, but not delete them. Use it to
  201. X                        see if you aren't about to destroy your work!
  202. X
  203. XEqualize will scan all files at SOURCE and it's subdirectories and
  204. Xcompare them to the files at DESTINATION and the corresponding
  205. Xsubdirectories. ALL files at DESTINATION that can't be found in
  206. XSOURCE will be DELETED!!! This goes for directory trees, too!!!
  207. X
  208. XWARNING!!! Use this beast only when you know what you're doing! :-)
  209. X
  210. XBTW, the name of this utility wasn't inspired by the TV series
  211. X"The Equalizer". Or was it? :-)
  212. X
  213. XIn this version, filenames or directories containing blanks
  214. X(like "My Dir:My File"), are NOT supported!  */
  215. X
  216. X/* This is Public Domain, read the source and learn */
  217. X
  218. Xsay 'Equalize 1.3 (09-Feb-89) by <CB>'
  219. X
  220. X/* open the Rexx support library */
  221. X
  222. Xif ~show('L',"rexxsupport.library") then do
  223. X   if addlib('rexxsupport.library',0,-30,0) then
  224. X      say 'added rexxsupport.library'
  225. X   else do;
  226. X      say 'support library not available'
  227. X      exit 10
  228. X      end
  229. X   end
  230. X
  231. Xaddress command
  232. Xcall pragma 'priority',-1
  233. X
  234. Xarg rein
  235. X
  236. X/* The parser */
  237. Xcopt = 'clone'
  238. X
  239. Xif words(rein) < 2 then do
  240. X        say 'Come on, gimme a SOURCE *AND* a DESTINATION path'
  241. X        say 'Ya better try again... Bye!'
  242. X        exit 10
  243. Xend
  244. X
  245. X
  246. Xroot = subword(rein,1,1)
  247. Xdest = subword(rein,2,1)
  248. Xdstat = 1
  249. X
  250. Xif ~ exists(root) then do
  251. X        say 'Source not found'
  252. X        say 'Exiting... Check your parameters'
  253. X        exit 10
  254. Xend
  255. X
  256. Xif ~ exists(dest) then do
  257. X        say 'Destination not found'
  258. X        say 'Exiting... Check your parameters'
  259. X        exit 15
  260. Xend
  261. X
  262. Xif words(rein) > 2 then do
  263. X        if subword(rein,3,1) = '-P' then
  264. X                dstat = 0
  265. Xend
  266. X
  267. Xif right(root,1) ~= ':' then
  268. X  root = root || '/'
  269. Xif root = '/' then root = ''
  270. X
  271. Xif right(dest,1) ~= ':' then
  272. X  dest = dest || '/'
  273. Xif dest = '/' then dest = ''
  274. X
  275. Xdlen = length(dest)
  276. X
  277. Xbytes = 0
  278. Xfiles = 0
  279. Xdircount = 1
  280. X
  281. Xsay 'Equalize is doing it''s job on 'dest
  282. X
  283. Xcall dolist(dest)
  284. X
  285. Xsay 'Deleted:' files 'files in a total 'dircount' directories.'
  286. Xsay 'This equalization cleared:' bytes 'Bytes.'
  287. Xsay
  288. Xexit 0
  289. X
  290. X
  291. X/* The real thing */
  292. X
  293. Xdolist: procedure expose files root dest dlen dircount bytes dstat
  294. Xparse arg x
  295. Xcontents = showdir(x);
  296. Xdo i = 1 to words(contents)
  297. X  temp = x || word(contents,i)
  298. X  type = statef(temp)
  299. X  if word(type,1) = 'FILE' then
  300. X    do
  301. X        snam = root || right(temp,(length(temp) - dlen))
  302. X        if ~ exists(snam) then
  303. X        do
  304. X                files = files + 1
  305. X                bytes = bytes + word(type,2)
  306. X                if dstat = 1 then
  307. X                do
  308. X                        'delete 'temp
  309. X                        say 'Deleted: 'temp
  310. X                end
  311. X                else say 'Would have deleted: 'temp
  312. X        end
  313. X    end
  314. X  if word(type,1) ='DIR' then do
  315. X        subdir = root || right(temp,(length(temp) - dlen))
  316. X        if ~ exists(subdir) then
  317. X          do
  318. X                say 'Subdirectory 'subdir' not found...'
  319. X                if dstat = 1 then
  320. X                do
  321. X                        'delete 'temp' all'
  322. X                        say 'Removed: 'temp
  323. X                end
  324. X                else say 'Would have removed: 'temp
  325. X          end
  326. X        call dolist(temp || '/')
  327. X        dircount = dircount + 1
  328. X  end
  329. Xend
  330. Xreturn
  331. SHAR_EOF
  332. echo "End of archive 1 (of 1)"
  333. # if you want to concatenate archives, remove anything after this line
  334. exit
  335.